/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DBLayer;
import java.sql.*;

/**
 *
 * @author Claus
 */
public class DBCountry implements IFDBCountry
{

	private  Connection con;
    /** Creates a new instance of DBCustomer */
    public DBCountry()
    {
      con = DBConnection.getInstance().getDBcon();
    }


	public String getCountryName(String countryCode)
	{
		ResultSet results;
		String query="SELECT cCode, phoneCode, cName FROM Country WHERE cCode = " + "'" + countryCode + "'";

		String returnString = "";

		try{
            Statement stmt = con.createStatement();
            stmt.setQueryTimeout(5);
            results = stmt.executeQuery(query);

            if( results.next() )
            {
				returnString = results.getString("cName");
            }
            else{
                returnString = null;
            }
        }
		catch(Exception e)
		{
			System.out.println("Land ikke fundet");
		}

		return returnString;

	}
}
